package ptij.vocoder.baseModel.closed_loop;

import ptolemy.actor.*;
import ptolemy.kernel.*;
import ptolemy.kernel.util.*;
import ptolemy.data.ObjectToken;
import ptolemy.data.Token;
import ptolemy.data.type.*;

import ptij.vocoder.baseModel.*;

//////////////////////////////////////////////////////////////////////////
//// PredLt6
/**

@author Ivan Jeukens
@version v 0.1 07/08/2003
*/
public class PredLt6 extends TypedAtomicActor {

    public PredLt6(CompositeEntity container, String name) throws
            IllegalActionException, NameDuplicationException {
        super(container, name);

        exc = new TypedIOPort(this, "exc", true, false);
        exc.setTypeEquals(BaseType.OBJECT);

        t0 = new TypedIOPort(this, "t0", true, false);
        t0.setTypeEquals(BaseType.OBJECT);

        frac = new TypedIOPort(this, "frac", true, false);
        frac.setTypeEquals(BaseType.OBJECT);

        exc_out = new TypedIOPort(this, "exc_out", false, true);
        exc_out.setTypeEquals(BaseType.OBJECT);

        txdtx_ctrl = new TypedIOPort(this, "txdtx_ctrl", true, false);
        txdtx_ctrl.setTypeEquals(BaseType.OBJECT);
    }

    ///////////////////////////////////////////////////////////////////
    ////                     ports and parameters                  ////

    // Input ports
    public TypedIOPort exc;
    public TypedIOPort t0;
    public TypedIOPort frac;
    public TypedIOPort txdtx_ctrl;

    // Output Ports
    public TypedIOPort exc_out;

    ///////////////////////////////////////////////////////////////////
    ////                         public methods                    ////

    public void initialize() throws IllegalActionException {
        super.initialize();
    }

    public void fire() throws IllegalActionException {
        ObjectToken obj = (ObjectToken) txdtx_ctrl.get(0);
        Short txdtx = (Short) obj.getValue();
        if((txdtx.shortValue() & Cnst.TX_SP_FLAG) != 0) {
            obj = (ObjectToken) exc.get(0);
            Short [] arg1 = (Short []) obj.getValue();

            obj = (ObjectToken) t0.get(0);
            Short arg2 = (Short) obj.getValue();

            obj = (ObjectToken) frac.get(0);
            Short arg3 = (Short) obj.getValue();

            Short [] res = _pred_lt6(arg1, arg2, arg3);

            exc_out.broadcast(new ObjectToken(res));
        }
    }

    ///////////////////////////////////////////////////////////////////
    ////                         private methods                   ////

    private Short [] _pred_lt6(Short [] exc, Short T0, Short frac) {

        return null;
    }

    ///////////////////////////////////////////////////////////////////
    ////                         private variables                 ////

}
